-- CALC_COMMON_TRAP_EFFECT

-- 计算陷阱的各类效果
-- @param trapId    陷阱id
-- @param key       类型
-- @param args      参数
return function(trapId, key, args)
    local layer = DungeonM.currentLayer();
    local co = args["co"] or 0;
    local base = args["base"] or 0;

    if key == "self_damage" then
        return args["damage"] or 0;
    elseif key == "damage" then
        if type(args["damage"]) == "number" then
            return args["damage"];
        end
        local damage = math.modf(math.ceil(co * layer + base))

        -- 额外增加的伤害
        local cannon = FormulaM.invoke("CALC_CANNON_ADDITION_DAMAGE");
        damage = damage + cannon;

        return damage;
    elseif key == "apply" then
        return args;
    else
        return args;
    end
end